Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: QuickTime

Previous | Overview | Contents | Next |

Constraining Compressed Data

The Image Compression Manager provides two functions and a data structure that allow your application to communicate information to compressors that can constrain compressed data to a specific data rate. Compressors indicate that they can constrain the data rate by setting the following flag in their compressor information structure:

#define codecInfoDoesRateConstrain(1L<<23)

(For details, see "The Compressor Information Structure," .)

The DataRateParams data type defines the data rate parameters structure.

typedef struct {
    long        dataRate;                       /* bytes per second */
    long        dataOverrun;                    /* number of bytes outside
                                                    rate */
    long        frameDuration;                  /* in milliseconds */
    long        keyFrameRate;                   /* frequency of key frames */
    CodecQ      minSpatialQuality;              /* minimum spatial quality */
    CodecQ      minTemporalQuality;             /* minimum temporal quality */
} DataRateParams;
typedef DataRateParams *DataRateParamsPtr;
dataRate
Specifies the bytes per second to which the data rate must be constrained.

dataOverrun
Indicates the current number of bytes above or below the desired data rate. A value of 0 means that the data rate is being met exactly. If your application doesn't know the data overrun, it should set this field to 0.

frameDuration
Specifies the duration of the current frame in milliseconds.

keyFrameRate
Indicates the frequency of key frames. This frequency is normally identical to the key frame rate passed to the CompressSequenceBegin function (described on CompressSequenceBegin ).

minSpatialQuality
Specifies the minimum spatial quality the compressor should use to meet the requested data rate. See "Compression Quality Constants," for available values.

minTemporalQuality
Indicates the minimum temporal quality the compressor should use to meet the requested data rate. See "Compression Quality Constants," for available values.

The SetCSequenceDataRateParams function allows you to specify the parameters in this structure and the GetCSequenceDataRateParams function allows you to retrieve the parameters.

SetCSequenceDataRateParams

The SetCSequenceDataRateParams function allows your application to set parameters in the data rate parameters structure, which communicates information to compressors that can constrain compressed data in a particular sequence to a specific data rate.

pascal OSErr SetCSequenceDataRateParams
                                         (ImageSequence seqID,
                                          DataRateParamsPtr params);
seqID
Contains the unique sequence identifier that was returned by the CompressSequenceBegin function (described on CompressSequenceBegin ).

params
Points to the data rate parameters structure to be associated with the sequence identifier specified in the seqID parameter.

DESCRIPTION

If your application is keeping track of data overrun, you should call the SetCSequenceDataRateParams function before each use of the CompressSequenceFrame function (described on CompressSequenceFrame ). If not, you only need to call SetCSequenceDataRateParams before the first use of CompressSequenceFrame , with the dataOverrun parameter of the data rate parameters structure set to 0. In this case, it is assumed that the frame duration is valid for all frames. Setting the dataRate field in the data rate parameters structure to 0 is the same as not performing data rate constraint.

RESULT CODES

noErr

0

No error

paramErr

-50

Invalid parameter specified

GetCSequenceDataRateParams

The GetCSequenceDataRateParams function obtains the data rate parameters previously set with the SetCSequenceDataRateParams function, which is described in the previous section.

pascal OSErr GetCSequenceDataRateParams
                                         (ImageSequence seqID,
                                          DataRateParamsPtr params);
seqID
Contains the unique sequence identifier that was returned by the CompressSequenceBegin function (described on CompressSequenceBegin ).

params
Points to the data rate parameters structure associated with the sequence identifier specified in the seqID parameter.

RESULT CODES

noErr

0

No error

paramErr

-50

Invalid parameter specified


© 1999 Apple Computer, Inc.

Previous | Overview | Contents | Next